#ifndef MEDIALISTMODEL_H
#define MEDIALISTMODEL_H

#include <QAbstractListModel>
#include "AbstractMediaSource.h"
#include "QDir"

class MediaSourceFactoryInterface;

class MediaListModel : public QAbstractListModel
{
   Q_OBJECT
public:
   explicit MediaListModel( MediaSourceFactoryInterface *mediaFactory, QObject *parent = 0);
   ~MediaListModel();

   int rowCount(const QModelIndex &parent = QModelIndex()) const;

   QVariant data(const QModelIndex &index, int role) const;
   Qt::ItemFlags flags(const QModelIndex &index) const;

   void addMediaFile( const QString & fileName);
   const AbstractMediaSource *mediaData(const QModelIndex &index) const;
   QModelIndex indexForData(const AbstractMediaSource *data);

   bool insertRow(int row, const QModelIndex &parent = QModelIndex());
   bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
   bool moveRows(const QModelIndex &, int sourceRow, int count,
                 const QModelIndex &, int destinationChild);

   QModelIndex searchById( const QString & stringId);

public slots:
   void addMediaFiles( const QStringList & fileNames);

private:
   void moveRows(int sourceRow, int count, int destinationRow);
   QString createStringId( const QString &filename);
   bool setData(const QModelIndex &index, const AbstractMediaSource *value);

private:
   QList<const AbstractMediaSource *> m_mediaList;
   MediaSourceFactoryInterface *m_mediaFactory;
};

#endif // MEDIALISTMODEL_H
